import { defineStore } from "pinia"
import {
	ref,
	reactive
} from 'vue'

export const useDictStore = defineStore("dict", () => {
  const dict = ref({})
  const defaultFilter = ref({
	  maxAge:40,
	  minAge:24,
	  maxHeight:180,
	  minHeight:160,
	  maxIncome:2,
	  minIncome:2,
	  defaultMaxIncome:11000,
	  defaultMinIncome:8000,
	  maxWeight:60,
	  minWeight:40,
	  marryStatus:0,
	  educationalVal:'',
	  educational:'',
	  addressDistrict:'',
	  addressDistrictVal:'',
	  workId:'',
	  workIdVal:'',
	  buyHouse:'',
	  buyHouseVal:'',
	  buyCar:'',
	  buyCarVal:'',
	  isChild:'',
	  isChildVal:''
  })
  const filterConfig = ref(Object.assign({},defaultFilter.value))
  const setDict = (val) => {
	  dict.value = val
  }
  
  const getDict = () => {
	  return dict
  }
  
  const getDictDetail = (key,val) => {
	  if(key && val != undefined){
		  return dict.value[key].find(type => type.key === val).val
	  }
	  return ''
  }
  
  const getFilterConfig = () => {
	  return filterConfig.value
  }
  
  const resetFilterConfig = () => {
	  filterConfig.value = defaultFilter.value
	  console.log(defaultFilter.value)
	  console.log(filterConfig.value)
  }
  
  return {
	  getDict,
	  setDict,
	  getDictDetail,
	  getFilterConfig,
	  resetFilterConfig
  }
})
